<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CANopenNode: Object dictionary</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">CANopenNode
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__CO__SDO__objectDictionary.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Object dictionary<div class="ingroups"><a class="el" href="group__CO__CANopen__301.html">CANopen_301</a> &raquo; <a class="el" href="group__CO__SDOserver.html">SDO server</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>CANopen Object dictionary implementation in CANopenNode.  
<a href="#details">More...</a></p>
<p>CANopen Object dictionary implementation in CANopenNode. </p>
<p>CANopen Object dictionary is a collection of different data items, which can be used by the stack or by the application.</p>
<p>Each Object dictionary entry is located under 16-bit index, as specified by the CANopen:</p><ul>
<li>0x0001..0x025F: Data type definitions.</li>
<li>0x1000..0x1FFF: Communication profile area.</li>
<li>0x2000..0x5FFF: Manufacturer-specific profile area.</li>
<li>0x6000..0x9FFF: Standardized device profile area for eight logical devices.</li>
<li>0xA000..0xAFFF: Standardized network variable area.</li>
<li>0xB000..0xBFFF: Standardized system variable area.</li>
<li>Other: Reserved.</li>
</ul>
<p>If Object dictionary entry has complex data type (array or structure), then 8-bit subIndex specifies the sub-member of the entry. In that case subIndex 0x00 is encoded as uint8_t and specifies the highest available subIndex with that entry. Subindex 0xFF has special meaning in the standard and is not supported by CANopenNode.</p>
<h4>Object type of one Object dictionary entry</h4>
<ul>
<li>NULL: Not used by CANopenNode.</li>
<li>DOMAIN: Block of data of variable length. Data and length are under control of the application.</li>
<li>DEFTYPE: Definition of CANopen basic data type, for example INTEGER16.</li>
<li>DEFSTRUCT: Definition of complex data type - structure, which is used with RECORD.</li>
<li>VAR: Variable of CANopen basic data type. Subindex is 0.</li>
<li>ARRAY: Array of multiple variables of the same CANopen basic data type. Subindex 1..arrayLength specifies sub-member.</li>
<li>RECORD: Record or structure of multiple variables of different CANopen basic data type. Subindex specifies sub-member.</li>
</ul>
<h4>Implementation in CANopenNode</h4>
<p>Object dictionary in CANopenNode is implemented in CO_OD.h and CO_OD.c files. These files are application specific and must be generated by Object dictionary editor (application is included by the stack).</p>
<p>CO_OD.h and CO_OD.c files include:</p><ul>
<li>Structure definitions for records.</li>
<li>Global declaration and initialization of all variables, arrays and records mapped to Object dictionary. Variables are distributed in multiple objects, depending on memory location. This eases storage to different memories in microcontroller, like eeprom or flash.</li>
<li>Constant array of multiple Object dictionary entries of type <a class="el" href="structCO__OD__entry__t.html" title="Object for one entry with specific index in Object dictionary. ">CO_OD_entry_t</a>. If object type is record, then entry includes additional constant array with members of type <a class="el" href="structCO__OD__entryRecord__t.html" title="Object for record type entry in Object dictionary. ">CO_OD_entryRecord_t</a>. Each OD entry includes information: index, maxSubIndex, <a class="el" href="group__CO__SDOserver.html#ga0244f2d504e0de4f14614884d7319fd0" title="Object Dictionary attributes. ">CO_SDO_OD_attributes_t</a>, data size and pointer to variable.</li>
</ul>
<p>Function <a class="el" href="group__CO__SDOserver.html#gaecb9ebca7a4f074d5e73ba977d6c2243" title="Initialize SDO object. ">CO_SDO_init()</a> initializes object <a class="el" href="structCO__SDO__t.html" title="SDO server object. ">CO_SDO_t</a>, which includes SDO server and Object dictionary.</p>
<p>Application doesn't need to know anything about the Object dictionary. It can use variables specified in CO_OD.h file directly. If it needs more control over the CANopen communication with the variables, it can configure additional functionality with function <a class="el" href="group__CO__SDOserver.html#gab433430abe125bb16c08e7be3e034985" title="Configure additional functionality to one Object dictionary entry. ">CO_OD_configure()</a>. Additional functionality include: <a class="el" href="group__CO__SDO__OD__function.html">Object Dictionary function</a> and <a class="el" href="group__CO__SDOserver.html#ga954a22b6af836082afaf69b0f0cc4c7e" title="Bit masks for flags associated with variable from Object dictionary. ">CO_SDO_OD_flags_t</a>.</p>
<p>Interface to Object dictionary is provided by following functions: <a class="el" href="group__CO__SDOserver.html#ga2532cf0445a91285b6e06e67abb1135d" title="Find object with specific index in Object dictionary. ">CO_OD_find()</a> finds OD entry by index, <a class="el" href="group__CO__SDOserver.html#gad492842213f493a27c274b01c4e02075" title="Get length of the given object with specific subIndex. ">CO_OD_getLength()</a> returns length of variable, CO_OD_getAttribute returns attribute and <a class="el" href="group__CO__SDOserver.html#ga3ee04247261fbe560132584f727ed99d" title="Get pointer to data of the given object with specific subIndex. ">CO_OD_getDataPointer()</a> returns pointer to data. These functions are used by SDO server and by PDO configuration. They can also be used to access the OD by index like this.</p>
<div class="fragment"><div class="line">index = <a class="code" href="group__CO__SDOserver.html#ga2532cf0445a91285b6e06e67abb1135d">CO_OD_find</a>(<a class="code" href="group__CO__CANopen.html#gaa6b0e31a1f760af91bb742c83c00a6c1">CO</a>-&gt;<a class="code" href="structCO__t.html#a016095788ceedcad8b9014c3527a8b64">SDO</a>[0], <a class="code" href="group__CO__SDOserver.html#gga7940130bc04382e487b1153b8644e17eaf4eb4e0204ae9696f935af5d4fdcff7e">OD_H1001_ERR_REG</a>);</div><div class="line"><span class="keywordflow">if</span> (index == 0xffff) {</div><div class="line">    <span class="keywordflow">return</span>;</div><div class="line">}</div><div class="line">length = <a class="code" href="group__CO__SDOserver.html#gad492842213f493a27c274b01c4e02075">CO_OD_getLength</a>(<a class="code" href="group__CO__CANopen.html#gaa6b0e31a1f760af91bb742c83c00a6c1">CO</a>-&gt;<a class="code" href="structCO__t.html#a016095788ceedcad8b9014c3527a8b64">SDO</a>[0], index, 1);</div><div class="line"><span class="keywordflow">if</span> (length != <span class="keyword">sizeof</span>(new_data)) {</div><div class="line">   <span class="keywordflow">return</span>;</div><div class="line">}</div><div class="line"></div><div class="line">p = <a class="code" href="group__CO__SDOserver.html#ga3ee04247261fbe560132584f727ed99d">CO_OD_getDataPointer</a>(<a class="code" href="group__CO__CANopen.html#gaa6b0e31a1f760af91bb742c83c00a6c1">CO</a>-&gt;<a class="code" href="structCO__t.html#a016095788ceedcad8b9014c3527a8b64">SDO</a>[0], index, 1);</div><div class="line"><span class="keywordflow">if</span> (p == <a class="code" href="group__CO__dataTypes.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {</div><div class="line">    <span class="keywordflow">return</span>;</div><div class="line">}</div><div class="line"><a class="code" href="group__CO__critical__sections.html#ga3850830931ced2bd3d7e15821572bbcc">CO_LOCK_OD</a>();</div><div class="line">*p = new_data;</div><div class="line"><a class="code" href="group__CO__critical__sections.html#ga2477f5d24fd31a9f4052cf451b87809f">CO_UNLOCK_OD</a>();</div></div><!-- fragment --><p>Be aware that accessing the OD directly using CO_OD.h files is more CPU efficient as <a class="el" href="group__CO__SDOserver.html#ga2532cf0445a91285b6e06e67abb1135d" title="Find object with specific index in Object dictionary. ">CO_OD_find()</a> has to do a search everytime it is called. </p>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Tue Jun 9 2020 17:29:32 for CANopenNode by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
